package mapper;

import com.sqnu.javabean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

public interface UserMapper {
    List<User> selectAll();
    @Update({
            "UPDATE user",
            "<set>",
            "<if test=\"username != null\">username = #{username},</if>",
            "<if test=\"password != null\">password = #{password},</if>",
            "<if test=\"phone != null\">phone = #{phone},</if>",
            "</set>",
            "WHERE uid = #{uid}"
    })
    int updateUser(User user);
    @Delete({"<script>        delete from user where uid in\n" +
            "        <foreach collection=\"array\" item=\"uid\" open=\"(\" close=\")\" separator=\",\">\n" +
            "            #{uid}\n" +
            "        </foreach></script>"})
    int deleteByArray(int[] array);
}
